.<template>
  <div class="login">
      <div><input type="text" v-model="user" placeholder="用户名"></div>
      <div><input type="text" v-model="pwd" placeholder="密码"></div>
      <div><button @click="login">登录</button></div>
      <div><button @click="goregisity">注册</button></div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data () {
        return {
            user:'',
            pwd:''
        }
    },
    methods: {
        login(){
           axios.post('/api/login',{user:this.user,pwd:this.pwd}).then(res=>{
               if(res.data.code){
                this.$router.push(`/index/home?id=${res.data.id}`)
               }else{
                   alert(res.data.msg)
               }
               
           })
        
        },
        goregisity(){
            this.$router.push('/regisity');
        }
    }
}
</script>

<style lang='scss'>
.login{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    input{
        width: 250px;
        height: 50px;
        margin: 5px 0;
        text-indent: 1em;
        border-radius: 10px;
        outline: none;
        border: 1px solid #ccc;
    }
    button{
        width: 225px;
        height: 40px;
        margin: 5px 0;
        background-color: cornflowerblue;
        border-radius: 10px;
        outline: none;
        border: 0;
    }
}
</style>